import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.geom.Shape;

import net.phys2d.math.ROVector2f;
import net.phys2d.math.Vector2f;
import net.phys2d.raw.Body;
import net.phys2d.raw.shapes.Box;


public class Entity {

	public float x,
				 y,
				 width,
				 height,
				 weight;
	public Body body;
	public String id;
	public boolean removeoffscreen;
	public Color color;
	
	public Entity(float x, float y, float width, float height, float weight) {
		this.x = x;
		this.y = y;
		this.width = width;
		this.height = height;
		this.weight = weight;
		this.body = new Body(new Box(width, height), weight);
		this.body.setPosition(x, y);
		this.removeoffscreen = true;
		color = null;
		}
	
	public Entity(float x, float y) {
		this(x,y,0.0f,0.0f,0.0f);
	}
	public Entity() {
		x = 0.0f;
		y = 0.0f;
		width = 0.0f;
		height = 0.0f;
		weight = 0.0f;
		body = null;
		removeoffscreen = true;
	}
	
	public void move(float x, float y, GameContainer gc) {
		body.addForce(new Vector2f(x,y));
	}


	protected void setPosition(float x, float y, boolean removeForce) {
		this.x = x;
		this.y = y;
		body.setPosition(x,y);
		if (removeForce) {
			body.setForce(0.0f, 0.0f);
			body.setRotation(0.0f);
			float xvel = body.getVelocity().getX();
			float yvel = body.getVelocity().getY();
			body.adjustVelocity(new Vector2f(-xvel, -yvel));
		}
	}
	
	public float getX() {
		return body.getPosition().getX();
	}
	
	public float getY() {
		return body.getPosition().getY();
	}
}
